import time
from generator import generate_random_data, generate_sorted_data, generate_reverse_sorted_data, generate_partial_sorted_data
from alg import shell_sort

def test_sorting_algorithm(sort_func, data, algorithm_name):
    start_time = time.time()
    sorted_data = sort_func(data)
    end_time = time.time()

    is_sorted = all(sorted_data[i] <= sorted_data[i + 1] for i in range(len(sorted_data) - 1))
    print(f"Testing {algorithm_name} with {len(data)} elements:")
    print(f"Sorted correctly: {is_sorted}")
    print(f"Execution time: {end_time - start_time:.6f} seconds")
    print()

def main():
    sizes = [100, 1000, 5000]
    for size in sizes:
        data = generate_random_data(size)
        test_sorting_algorithm(shell_sort, data, "Shell Sort")
        data = generate_sorted_data(size)
        test_sorting_algorithm(shell_sort, data, "Shell Sort")
        data = generate_reverse_sorted_data(size)
        test_sorting_algorithm(shell_sort, data, "Shell Sort")
        data = generate_partial_sorted_data(size)
        test_sorting_algorithm(shell_sort, data, "Shell Sort")

if __name__ == '__main__':
    main()
